﻿import mx.utils.Delegate;
import gs.TweenLite;
import btn;
class eff.LeeYueCircle extends MovieClip {
	//设置界限
	var id, lid, cCtrl, sCtrl, _data,_data3;
	var callback, tiaojian, tjOK; 
	var EndX;
	var 动用透明吗;
	var onB2F, onF2B, onTar, onLoadOK, onLeave, scope, doM2;
	var onDataChange:Function;
	function LeeYueCircle() {
	}
	public function onLoad() {
		new AS2.MC_VV(1, "25,50,100,160", "0,40,100,0");
		trace("onLoad called");
		this.createEmptyMovieClip('sCtrl', -9998);
		this.createEmptyMovieClip('cCtrl', -9999);
		//
		this.watch("4", Delegate.create(this, function (prop, oldvv, nowvv) {
			this.EndX = nowvv;
		}));
		/*
		this.watch("m2", Delegate.create(this, function (prop, oldvv, nowvv) {
			this.doM2 = nowvv;
		}));*/
		this.watch("id", Delegate.create(this, function (prop, oldvv, nowvv) {
			var nid = nowvv;
			this._visible = ((nid == 0 && lid == 3) || (nid == 3 && lid == 0)) ? false : true; 
			if(this.lid==2 && (nid == 1||nid == 3)) Delegate.create(scope,onLeave)({it:this,bs:bs});
			if(lid == 0 && nid == 1 )	this._visible =true;
			if(lid == 3 && nid == 2 )	this._visible =true; 
			if(nid == 0 && lid == 3)	onF2B({it:this})
			if(nid == 3 && lid == 0)	onB2F({it:this})  
			lid = nid;
		}));
		Delegate.create(scope,onLoadOK)();
	}
	public function onUnload() {
		//dispose();
	}
	function dispose() {
		removeMovieClip(this)
	}
	function get bs():Array{
			var arr=[]
			for(var i=0;i<10;i++){
				arr.push(this['cttr']['pp'+i]);
			}
			return arr;
		
	}
	function set data(a ) { 
		this._data = a;
		onDataChange({it:this,data:this._data});
		
	}
	function get data():Array {
		return this._data;
	}
	// 重要函数
	function doCB() {
		if (Math.abs(this.EndX-this._xscale)<tiaojian ) {
			if (!this['tjOK']) {
				callback({name:this._name});
				this['tjOK'] = 1;
			}
		}
	}
	function applyScale() {
		doCB();
		if (Math.abs(this.EndX-this._xscale)<0.3) {  
			this._xscale = this._yscale=this.EndX;
			this._alpha= AS2.MC_VV.getVV(1,this._xscale); 
			if(this.lid==2) Delegate.create(scope,onTar)({it:this,data:this.data,bs:bs});
			this.removeEvent();
		}
		this._xscale += ((this.EndX)-this._xscale)*0.1;
		this._yscale += ((this.EndX)-this._yscale)*0.1;
		//* 
		if (this.动用透明吗)this._alpha= AS2.MC_VV.getVV(1,this._xscale);
	}
	function initPos() {
		this._visible = true; 
		this._xscale = this._yscale=this.EndX;
		this._visible = (this.lid == 0 || this.lid == 3) ? false : true;  
		if (this.动用透明吗)this._alpha= AS2.MC_VV.getVV(1,this._xscale);
	}
	//
	function removeEvent() {  
		this.sCtrl.onEnterFrame = null;
		delete this.sCtrl.onEnterFrame;
	}
	function open() {
		//trace('这里重新');  
		this.sCtrl.onEnterFrame = Delegate.create(this, applyScale);
	}
	function onCase(tiaojian, callback) {
		this.tiaojian = tiaojian;
		this.callback = callback;
		tjOK = 0;
	}
	function close() {
	} 
} 
